<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-redpacket_fill"></i> 支持作者
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="plugins-tips">如果平台对你有帮助，那就请作者喝杯饮料吧！如有疑问，请联系17522284448@qq.com</div>
            <div>
                <el-form ref="form" :model="order" label-width="80px">
                    <el-form-item label="金额￥">
                        <el-input v-model="order.total_amount"></el-input>
                    </el-form-item>
                    <el-form-item label="留言">
                        <el-input v-model="order.body"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit">立即创建</el-button>
                        <el-button>取消</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    import api from "../api/index"
export default {
    name: "donate",
    data(){
        return{
            order:{
                out_trade_no:null,
                subject:null,
                total_amount:null,
                body:null
            }
        }
    },
    methods: {
        onSubmit() {
            api.pay(this.order).then(resp=>{
                //this.$router.push({path: '/pay',query:{ res}});
                const divForm = document.getElementsByTagName('div')
                if (divForm.length) {
                    document.body.removeChild(divForm[0])
                }
                const div = document.createElement('div');
                div.innerHTML = resp.data; // data就是接口返回的form 表单字符串
                document.body.appendChild(div);
                document.forms[0].setAttribute('target', '_blank'); // 新开窗口跳转
                document.forms[0].submit();
            });
        },
    }
};
</script>

<style>
</style>
